package cn.tedu.baking.controller;

import cn.tedu.baking.pojo.vo.CategoryVO;
import cn.tedu.baking.response.common.JsonResult;
import cn.tedu.baking.service.ICategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Author：毕龙
 * Date: 2024/8/15 10:50
 */
@RestController
@RequestMapping("/v1/categories/")
@Slf4j
public class CategoryController {

    @Autowired
    private ICategoryService iCategoryService;

    public CategoryController(){
        log.debug("创建CategoryController对象");
    }

    @GetMapping("{type}/getCategories")
    public JsonResult getCategories(@PathVariable Integer type){
        log.debug("获取父级的id：{}", type);
        List<CategoryVO> list = iCategoryService.getCategories(type);
        return JsonResult.ok(list);
    }
}
